package com.googlecode.wmlynar.javadoctc.util;

import com.thoughtworks.qdox.model.JavaMethod;
import com.thoughtworks.qdox.model.JavaParameter;
import com.thoughtworks.qdox.model.Type;

public class QdoxUtils {

	public static String getTypeValueWithDimensions(Type type) {
		StringBuilder sb = new StringBuilder();
		sb.append(type.getGenericValue());
		for(int i=0; i<type.getDimensions(); i++) {
			sb.append("[]");
		}
		return sb.toString();
	}

	public static String getMethodSignature(JavaMethod method) {
		StringBuilder sb = new StringBuilder();
		sb.append(method.getName());
		sb.append("(");
		JavaParameter[] parameters = method.getParameters();
		boolean appendComma = false;
		for(JavaParameter p : parameters) {
			if(appendComma) {
				sb.append(",");
			} else {
				appendComma = true;
			}
			sb.append(getTypeValueWithDimensions(p.getType()));
		}
		sb.append(")");
		return sb.toString();
	}

}
